Function CurrentSAPguiVersion
   'modification
	Set objFSO = CreateObject("Scripting.FileSystemObject") 
	If objFSO.FileExists(Get_OS_Disk() & "Program Files\SAP\FrontEnd\SAPgui\SAPgui.exe") then 
		CurrentSAPguiVersion = objFSO.GetFileVersion("C:\Program Files\SAP\FrontEnd\SAPgui\SAPgui.exe") 
	end if
	If  objFSO.FileExists(Get_OS_Disk() & "Program Files (x86)\SAP\FrontEnd\SAPgui\SAPgui.exe") Then
		CurrentSAPguiVersion = objFSO.GetFileVersion("C:\Program Files (x86)\SAP\FrontEnd\SAPgui\SAPgui.exe") 
	else
		CurrentSAPguiVersion = "Version Unknown"
	End If
	Set objFSO = nothing
End Function




'=================================sap functions=================================
Function PopUpWin_Continue
		Set SAPsession = description.Create
		'SAPsession("program").value = ".*"
		SAPsession("type").value = "GuiSession"	
		Set PopUpWin =  description.Create
		PopUpWin("type").value = "GuiModalWindow"		
		
		If  SAPGuiSession(SAPsession).SAPGuiWindow(PopUpWin).Exist(5)Then
			SAPGuiSession(SAPsession).SAPGuiWindow(PopUpWin).SendKey 0 
		End If
		wait 1	
		set	PopUpWin = nothing	
		set SAPsession = nothing
End Function


Function Warning_Save
		Set SAPsession = description.Create
		'SAPsession("program").value = ".*"
		SAPsession("type").value = "GuiSession"	
		Set PopUpWin =  description.Create
		PopUpWin("type").value = "GuiModalWindow"   		
		If  SAPGuiSession(SAPsession).SAPGuiWindow(PopUpWin).Exist(5)Then
			SAPGuiSession(SAPsession).SAPGuiWindow(PopUpWin).Sapguibutton("Text:=Save").click
		End If
		wait 1	
		set	PopUpWin = nothing	
		set SAPsession = nothing
End Function

Function BackF3
	Set SAPsession = description.Create
	SAPsession("program").value = ".*"
	SAPsession("type").value = "GuiSession"
	SAPsession("index").value = 1
	Set SAPWin = description.Create
	SAPWin("text").value = ".*"
	SAPWin("type").value = "GuiMainWindow"
	SAPGuiSession(SAPsession).SAPGuiWindow(SAPWin).SendKey F3
	wait 1
	Set SAPWin = nothing 
	set SAPsession = nothing
End Function

Function  SaveCtrl_S
	Set SAPsession = description.Create
	SAPsession("program").value = ".*"
	SAPsession("type").value = "GuiSession"
	Set SAPWin = description.Create
	SAPWin("text").value = ".*"
	SAPWin("type").value = "GuiMainWindow"
	Set SaveButton = description.Create	
	SaveButton("name").value = "btn\[11\]"	
	SaveButton("guicomponenttype").value = "40"
	Dim editble
	editble = SAPGuiSession(SAPsession).SAPGuiWindow(SAPWin).SAPGuiButton(SaveButton).GetROProperty("Changeable")
	If  editble Then
		SAPGuiSession(SAPsession).SAPGuiWindow(SAPWin).SAPGuiButton(SaveButton).Click
	End If
	wait 1
	Set SaveButton = nothing
	Set SAPWin = nothing
	Set SAPsession = nothing
End Function

Function  WarningMsg_Enter
   Set SAPsession = description.Create
	SAPsession("type").value = "GuiSession"
	Set SAPWin = description.Create
	SAPWin("text").value = ".*"
	SAPWin("type").value = "GuiMainWindow"
	Set Statusbar = description.Create
	Statusbar("name").value = "sbar"
	Statusbar("type").value = "GuiStatusbar"
	Dim temptext
	Dim temptype
	temptext =""
	If  SAPGuiSession(SAPsession).SAPGuiWindow(SAPWin).SAPGuiStatusBar(Statusbar).Exist Then            		
		temptext = SAPGuiSession(SAPsession).SAPGuiWindow(SAPWin).SAPGuiStatusBar(Statusbar).GetROProperty("Text")
		temptype = SAPGuiSession(SAPsession).SAPGuiWindow(SAPWin).SAPGuiStatusBar(Statusbar).GetROProperty("messagetype")
		If  temptext <>"" and temptype = "W" Then
			SAPGuiSession(SAPsession).SAPGuiWindow(SAPWin).SendKey 0 
			wait 1
		End If
	End If	
	Set SAPsession = nothing
	Set SAPWin = nothing
	Set Statusbar = nothing
End Function

Function GetStatusBarItem(ItemName)
	Set SAPsession = description.Create
	SAPsession("type").value = "GuiSession"
	Set SAPWin = description.Create
	SAPWin("text").value = ".*"
	SAPWin("type").value = "GuiMainWindow"
	Set Statusbar = description.Create
	Statusbar("name").value = "sbar"
	Statusbar("type").value = "GuiStatusbar"
	Dim temptext
	temptext = ""
	temptext = SAPGuiSession(SAPsession).SAPGuiWindow(SAPWin).SAPGuiStatusBar(Statusbar).GetROProperty(ItemName)
	If  temptext<>""Then
		temptext = cstr(temptext)
	End If
	Set SAPsession = nothing
	Set SAPWin = nothing
	Set Statusbar = nothing
	GetStatusBarItem = temptext
End Function

Function Statusbar_CurrentStatus
	Set SAPsession = description.Create
	SAPsession("type").value = "GuiSession"
	Set SAPWin = description.Create
	SAPWin("text").value = ".*"
	SAPWin("type").value = "GuiMainWindow"
	Set Statusbar = description.Create
	Statusbar("name").value = "sbar"
	Statusbar("type").value = "GuiStatusbar"
	Dim status
	If SAPGuiSession(SAPsession).SAPGuiWindow(SAPWin).SAPGuiStatusBar(Statusbar).Exist(2) Then
		Statusbar_CurrentStatus = SAPGuiSession(SAPsession).SAPGuiWindow(SAPWin).SAPGuiStatusBar(Statusbar).GetROProperty("messagetype")
	else
		Statusbar_CurrentStatusn = ""
	End If
	Set SAPsession = nothing
	Set SAPWin = nothing
	Set Statusbar = nothing
End Function

'get information of statusbar
Function StatusBarText()
	Set SAPsession = description.Create
	SAPsession("program").value = "SAP.*"
	SAPsession("type").value = "GuiSession"
	Set SAPWin = description.Create
	SAPWin("text").value = ".*"
	SAPWin("type").value = "GuiMainWindow"
	Set Statusbar = description.Create
	Statusbar("name").value = "sbar"
	Statusbar("type").value = "GuiStatusbar"
	Dim temptext	
	temptext =""
	If  SAPGuiSession(SAPsession).SAPGuiWindow(SAPWin).SAPGuiStatusBar(Statusbar).Exist(2) Then 
		temptext = SAPGuiSession(SAPsession).SAPGuiWindow(SAPWin).SAPGuiStatusBar(Statusbar).GetROProperty("Text")
		if temptext <>"" then
			'SAPGuiSession(SAPsession).SAPGuiWindow(SAPWin).SAPGuiStatusBar(Statusbar).highlight 
			Dim ix,iy,iw,ih
			ix = SAPGuiSession(SAPsession).SAPGuiWindow(SAPWin).SAPGuiStatusBar(Statusbar).GetROProperty("ScreenLeft")
			iy = SAPGuiSession(SAPsession).SAPGuiWindow(SAPWin).SAPGuiStatusBar(Statusbar).GetROProperty("ScreenTop")
			iw = SAPGuiSession(SAPsession).SAPGuiWindow(SAPWin).SAPGuiStatusBar(Statusbar).GetROProperty("Width")
			ih = SAPGuiSession(SAPsession).SAPGuiWindow(SAPWin).SAPGuiStatusBar(Statusbar).GetROProperty("Height")
			' Get the Desktop DC 
			hDC = Extern.GetWindowDC (Extern.GetDesktopWindow) 
			' Create a three pixel wide pen 
			hPen = Extern.CreatePen (6, 2, RGB(255, 0, 0)) ' PS_INSIDEFRAME, 3 , RGB(0, 0, 0) 
			Extern.SetROP2 hDC, 13
			Extern.SelectObject hDC, hPen 
			' Use an empty fill 
			Extern.SelectObject hDC, Extern.GetStockObject (5) ' NULL_BRUSH 
			' Do the highlight     
			Extern.Rectangle hDC, ix, iy, ix + iw, iy + ih
			wait 0,20		
			' CleanUp 
			Extern.ReleaseDC Extern.GetDesktopWindow, hDC 
			Extern.DeleteObject hPen 
		end if
	End If	
	
	Set SAPsession = nothing
	Set SAPWin = nothing
	Set Statusbar = nothing	
	StatusBarText = temptext
End Function

Function SetNextAsset(AssetName)
	DIC_Temp_Data.add "TempAsset",AssetName
end function

